﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using MbWsClient.Enum;
using MbWsClient.Classes;
using System.Drawing;
using MbWsClient.Service;

namespace MbWsClient
{
    public class AppSettings
    {
        private static MediaBrowserWsClient _mbServer;

        public static DirectoryInfo CacheDir
        {
            get
            {
                string path = ConfigHelper.GetConfigValue(ConfigSetting.CacheDir);
                return new DirectoryInfo(path);
            }
        }

        public static DirectoryInfo ImageCacheDir
        {
            get
            {
                string path = Path.Combine(CacheDir.FullName, "Images");
                return new DirectoryInfo(path);
            }
        }

        public static DirectoryInfo MetadataCacheDir
        {
            get
            {
                return new DirectoryInfo(Path.Combine(CacheDir.FullName, "Metadata"));
            }
        }

        public static DirectoryInfo ItemCacheDir
        {
            get
            {
                DirectoryInfo dir = new DirectoryInfo(Path.Combine(CacheDir.FullName, "Items"));
                dir.EnsureDirectoryExistance();
                return dir;
            }
        }

        public static MediaBrowserWsClient MbService
        {
            get
            {
                if (_mbServer == null)
                {
                    _mbServer = new MediaBrowserWsClient();
                }

                return _mbServer;
            }
        }

        public IEnumerable<Server> Servers
        {
            get
            {
                throw new NotImplementedException();
            }
        }

        public static string ServerName
        {
            get
            {
                string serverPath = ConfigHelper.GetConfigValue(ConfigSetting.ServiceAddress);
                Uri uri = new Uri(serverPath);
                return uri.Host;
            }
        }
    }
}
